package com.yilin.medical.utils;

import android.content.Context;
import android.view.View;

public class MeasureUtils {
	public static int customMeasureWidth(View view){
		 int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
	     int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
	     view.measure(w, h);
	     int width =view.getMeasuredWidth();
		return width;
		}
	
	public static int customMeasureHeight(View view){
		 int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
	     int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);
	     view.measure(w, h);
	     int height =view.getMeasuredHeight();
//	     int width =mAbTitleBar.getMeasuredWidth();
		return height;
		}
	public static int dip2px(Context context, float dipValue){ 
        final float scale = context.getResources().getDisplayMetrics().density; 
        return (int)(dipValue * scale + 0.5f); 
} 

	public static int px2dip(Context context, float pxValue){ 
        final float scale = context.getResources().getDisplayMetrics().density; 
        return (int)(pxValue / scale + 0.5f); 
} 
}
